const dayjs = require('dayjs')

const filterTime = (val, format = 'YYYY-MM-DD-HH-mm-SS') => {
  if (!isNull(val)) {
    val = parseInt(val) * 1000
    return dayjs(val).format(format)
  } else {
    return '--'
  }
}
export const isNull = (date) => {
  if (!date) return true
  if (JSON.stringify(date) === '{}') return true
  if (JSON.stringify(date) === '[]') return true
}
export default (Vue) => {
  Vue.prototype.$filters = {
    filterTime
  }
}
